home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videbjct / pnr4200d.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  20.0 KB  |  703 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoObject/RCS/Pioneer4200Driver.c,v 0.28 92/11/17 14:45:56 drapeau Exp $ */
  25. /* $Log:    Pioneer4200Driver.c,v $
  26.  * Revision 0.28  92/11/17  14:45:56  drapeau
  27.  * Improved diagnostic messages.  Cosmetic changes only.
  28.  * 
  29.  * Revision 0.27  92/09/28  12:39:53  drapeau
  30.  * PlayFromTo() was modified to reflect the new semantics of the VideoObject
  31.  * library.
  32.  * 
  33.  * Revision 0.26  92/07/30  15:28:41  drapeau
  34.  * Several changes:
  35.  * * Removed non-used functions.
  36.  * * Re-formatted all function declarations to conform to ANSI function
  37.  *   prototype standards.
  38.  * * Replaced hard-coded references to 30 frame-per-second frame rates with
  39.  *   new definition "FrameRate".  All math is based on this definition now,
  40.  *   allowing the driver to be used in places where the frame rate is not
  41.  *   30 fps.
  42.  * * Improved diagnostic messages.  Diagnostics now report the serial port
  43.  *   being used for the command when possible.
  44.  * 
  45.  * Revision 0.25  92/01/03  16:59:08  drapeau
  46.  * Modified Pioneer4200PlayFromTo() to fix an error in playback.  Before,
  47.  * the function always uses Pioneer4200PlayatSpeedDir, which sends a
  48.  * different opcode to the Pioneer4200 than Pioneer4200Play.  The
  49.  * opcode for PlayAtSpeedDir always mutes the audio, even if the
  50.  * speed is the normal 30 frames per second.  The function now checks for
  51.  * the device speed; if the speed is 30 fps, then the normal Pioneer4200Play
  52.  * is used; otherwise, Pioneer4200PlayAtSpeedDir is used.
  53.  * 
  54.  * Revision 0.24  91/09/30  17:06:27  lim
  55.  * Implemented Pioneer4200Ping.
  56.  * 
  57.  * Revision 0.23  91/08/24  17:50:02  lim
  58.  * Implemented PrintDiagnostics.
  59.  * 
  60.  * Revision 0.22  91/08/24  13:38:06  lim
  61.  * 1. Updated to use status codes in new PlayerStatus.h
  62.  * 2. Clear Marker() removed as part of video object.
  63.  * 
  64.  * Revision 0.21  91/08/20  16:29:04  lim
  65.  * Parameters for SetVideo : FeatureOff - Video mute
  66.  *                  FeatureOn - Video on
  67.  * 
  68.  * Revision 0.20  91/08/17  20:40:28  lim
  69.  * 1. Pause After Search is now implemented.
  70.  * 
  71.  * Revision 0.19  91/08/09  10:05:06  lim
  72.  * Fixed error regarding ErrorDecode().
  73.  * 
  74.  * 
  75.  * Revision 0.18  91/08/08  17:16:38  lim
  76.  *  1. PlayAtSpeedDir() - try to input device-dependent speed rather than an arbitrary speed.
  77.  *    ie use CalcSpeed before calling PlayAtSpeedDir()
  78.  * 2. CalcSpeed() - one parameter added, 'playMode'. If playMode is 1, it is used to calculate
  79.  *    device speed for segment play. If playMode is 0, it is used to calculate device speed for
  80.  *     normal play.
  81.  * 3. QueryMedium() - one parameter added, 'result'. Used to return non-integer results.
  82.  * 
  83.  * Revision 0.17  91/08/07  13:06:19  lim
  84.  * 1. Made as part of VideoLib.a. Removed references to vEdit application.
  85.  * 2. Added instance pointer, "theObject" to all public functions. 
  86.  * 3. ErrorDecode() is now a private function. It calls DisplayError() 
  87.  * (in 'videoObjects.c') to display the error message. 
  88.  * 
  89.  * Revision 0.16  91/08/02  12:51:38  lim
  90.  * 1. SetDefaults function changed to take in 4 parameters"
  91.  * audio, addressingMode, addressDisplayOnOff, and displayMode
  92.  * 2. xv_set is no longer called within driver code, but from
  93.  * vEdit application.
  94.  * 3. Pause is removed.
  95.  * 
  96.  * Revision 0.15  91/07/29  22:25:55  lim
  97.  * Updated all player statuses to conform with specs.
  98.  * 
  99.  * Revision 0.14  91/07/27  22:27:45  lim
  100.  * Changed speed to int from double.
  101.  * 
  102.  * Revision 0.13  91/07/23  15:51:55  lim
  103.  * 1. Set slider maximum to 120, minimum to -120. This is done because
  104.  * all devices will have to set their own slider max and min to match the
  105.  * max number of frames that they can play per second.
  106.  * 2. CalcSpeed and PlayAtSpeedDir has been changed to match change in
  107.  * slider values. It used to be that the slider value was twice the max
  108.  * number of frames so that 1.5 and 2.5 f/s speeds can be accommodated.
  109.  * 
  110.  * Revision 0.12  91/07/19  13:54:18  lim
  111.  * Fixed error : Eject is implemented with 2 "RJ"
  112.  * Changed Pioneer4200PlayFromTo :
  113.  * 1. Speed field is added.
  114.  * 2. NULL in from field means resume play, ie no search.
  115.  * 3. PlayAtSpeedDir used rather than Play.
  116.  * 4. Speed field changed from float to double.
  117.  * 
  118.  * Revision 0.11  91/07/17  22:49:03  lim
  119.  * Now SetDefaults also sets the Player in 'ready' state.
  120.  * 
  121.  * Revision 0.10  91/07/12  16:16:10  lim
  122.  * Initial revision implementing VideoObject.
  123.  *  */
  124.  
  125. #include "Pioneer4200Driver.h"
  126.  
  127. static char pioneer4200Rcsid[] = "$Header: /Source/Media/collab/VideoObject/RCS/Pioneer4200Driver.c,v 0.28 92/11/17 14:45:56 drapeau Exp $";
  128.  
  129. static char    diagMsg[64];
  130.  
  131.  
  132. /* Sets up default values for video options */
  133. int
  134.   Pioneer4200SetDefaults(VideoObject*    theObject,
  135.              int        audio,
  136.              int        addressingMode,
  137.              int        addressDisplayOnOff,
  138.              int        displayMode)
  139. {  
  140.   int status;
  141.   
  142.   status = Pioneer4200QueryStatus(theObject);
  143.   Pioneer4200SetAudio(theObject, audio);                /* set audio */
  144.   if ((status != PlayerDoorOpen) && (status != PlayerPark))
  145.     Pioneer4200SetAddMode(theObject, addressingMode);
  146.   Pioneer4200SetAddressDisplay(theObject, addressDisplayOnOff,
  147.                    displayMode);                /* set address display */
  148.   Pioneer4200Play(theObject);                        /* puts player in 'ready' state */
  149.   Pioneer4200Still(theObject);
  150.   return status;
  151. }                                    /* end function Pioneer4200SetDefaults */
  152.  
  153.  
  154. int
  155.   Pioneer4200SendCode(VideoObject*    theObject,
  156.               char*        code)
  157. {
  158.   char    in[20];
  159.   char    out[20];
  160.   char    errorMsg[50];
  161.   int    nr;
  162.   int    err;
  163.   int    num;
  164.   
  165.   sprintf(in, "%s\r", code);
  166.   sprintf(diagMsg, "%s :\tPioneer4200SendCode: sending ::%s::\n",
  167.       theObject->DevConfig->serialPort,
  168.       in);
  169.   PrintDiagnostics(diagMsg);
  170.   write(theObject->DevConfig->fd,in,strlen(in));
  171.   nr = read(theObject->DevConfig->fd,out,20);
  172.   if (theObject->DevConfig->eolChar == 13)                /* Is the device set up to return CR only? */
  173.     out[nr - 1] = '\0';                            /* Yes, don't terminate the string too early */
  174.   else                                    /* No, device returns CR and LF; terminate where the... */
  175.     out[nr - 2] = '\0';                            /* "CR" was */
  176.   sprintf(diagMsg, "%s :\tPioneer4200SendCode: read %d bytes ::%s::\n",
  177.       theObject->DevConfig->serialPort,
  178.       nr, out);
  179.   PrintDiagnostics(diagMsg);
  180.   if (out[0] == 'R')
  181.     return PlayerOk;
  182.   else if (out[0] == 'E') 
  183.   {
  184.     sscanf(&out[1],"%d",&err);
  185.     switch (err) 
  186.     {
  187.      case 0:
  188.       err = Pioneer4200CommunicationError;
  189.      case 4:
  190.       err = Pioneer4200FeatureNotAvailable;
  191.      case 6:
  192.       err = Pioneer4200MissingArgument;
  193.      case 11:
  194.       err = Pioneer4200NoDisc;
  195.      case 12:
  196.       err = Pioneer4200SearchError;
  197.      case 13:
  198.       err = Pioneer4200DefocussingError;
  199.      case 15:
  200.       err = Pioneer4200PictureStop;
  201.      case 99:
  202.       err = Pioneer4200PanicError;
  203.      default:
  204.       err = PlayerUnknownError;
  205.     }                                    /* end of switch (err) */
  206.     Pioneer4200ErrorDecode(theObject, -err, errorMsg);
  207.     return err;
  208.   }                                    /* end of else if (out[0] == 'E') */
  209.   else if (isdigit(out[0])) 
  210.   {
  211.     sscanf(out,"%d",&num);
  212.     return num;
  213.   }
  214.   else if (out[0] == 'P') 
  215.   {
  216.     sscanf(&out[1],"%d",&num);
  217.     if (strlen(&out[1]) == 2) 
  218.     {
  219.       switch (num) 
  220.       {
  221.        case 0:
  222.     return PlayerDoorOpen;
  223.        case 1:
  224.     return PlayerPark;
  225.        case 4:
  226.     return PlayerForwardPlay;
  227.        case 5:
  228.     return PlayerStill;
  229.        case 6:
  230.     return PlayerPause;
  231.        case 9:
  232.     return PlayerMultiSpeedPlay;
  233.        default:
  234.     return PlayerUnknownReturnCode;
  235.       }                                     /* end of switch (num) */
  236.     }                                                               /* end of if (strlen(&out[1]) == 2) */
  237.     else 
  238.       return num;
  239.   }                                    /* end of else if (out[0] == 'P') */
  240.   else if (out[0] == 'C') 
  241.   {
  242.     sscanf(&out[2],"%d",&num);
  243.     return num;
  244.   }
  245.   else 
  246.     return PlayerUnknownReturnCode;
  247. }                                    /* end function Pioneer4200SendCode */
  248.  
  249.  
  250.  
  251. /*  Player functions  */
  252.  
  253. int
  254.   Pioneer4200Stop(VideoObject* theObject)
  255. {
  256.   return(Pioneer4200SendCode(theObject, "PA"));                /* Implemented as a pause for maintaining 'ready' state */
  257. }                                    /* end function Pioneer4200Stop */
  258.  
  259.  
  260. int 
  261.   Pioneer4200Eject(VideoObject* theObject)
  262. {
  263.   Pioneer4200SendCode(theObject, "RJ");
  264.   return(Pioneer4200SendCode(theObject, "RJ"));
  265. }                                    /* end function Pioneer4200Eject */
  266.  
  267.  
  268.  
  269. int
  270.   Pioneer4200Start(VideoObject* theObject)
  271. {
  272.   return(Pioneer4200SendCode(theObject, "SA"));
  273. }                                    /* end function Pioneer4200Start */
  274.  
  275.  
  276. int
  277.   Pioneer4200Pause(VideoObject* theObject)
  278. {
  279.   return(Pioneer4200SendCode(theObject, "PA"));
  280. }                                    /* end function Pioneer4200Pause */
  281.  
  282.  
  283.  
  284. int
  285.   Pioneer4200Play(VideoObject* theObject)
  286. {
  287.   return(Pioneer4200SendCode(theObject, "PL"));
  288. }                                    /* end function Pioneer4200Play */
  289.  
  290.  
  291. int
  292.   Pioneer4200PlayFromTo(VideoObject*    theObject,
  293.             int        from,
  294.             int        to,
  295.             int        speed)
  296. {
  297.   char    fr[20];
  298.   int    status;
  299.   int    deviceSpeed;
  300.   
  301.   if ((from == to) || ((from > 0) && (to == 0)))            /* Case a & b: search to "from" and still (non-blocking... */
  302.   {                                    /* ...search doesn't apply here since search time is quick) */
  303.     return(Pioneer4200Search(theObject, from));                /* So both types of searches fall into the same search code */
  304.   }
  305.   if ((from == 0) && (to > 0))                        /* Case c: play from current position until address... */
  306.   {                                    /* ..."to" has been reached. */
  307.     Pioneer4200SetStop(theObject, to);                    /* This code makes the player return control ...*/
  308.     deviceSpeed = Pioneer4200CalcSpeed(theObject, speed, 0);        /* ... to the program once play has been started, ... */
  309.     if (deviceSpeed == FrameRate)                    /* ... instead of waiting until play has ended ...*/
  310.       return(Pioneer4200Play(theObject));
  311.     else
  312.       return(Pioneer4200PlayAtSpeedDir(theObject, deviceSpeed, Forward));
  313.   }
  314.   if ((from > 0) && (to > 0) && (from < to))                /* Case d: play from "from" to "to" */
  315.   {
  316.     Pioneer4200Search(theObject, from);
  317.     Pioneer4200SetStop(theObject, to);
  318.     deviceSpeed = Pioneer4200CalcSpeed(theObject, speed, 0);
  319.     if (deviceSpeed == FrameRate)
  320.       return(Pioneer4200Play(theObject));
  321.     else
  322.       return(Pioneer4200PlayAtSpeedDir(theObject, deviceSpeed, Forward));
  323.   }
  324.   return(PlayerReturnError);                        /* If this code is reached, incorrect from & to were requested */
  325. }                                    /* end function Pioneer4200PlayFromTo */
  326.  
  327.  
  328. int
  329.   Pioneer4200Still(VideoObject* theObject)
  330. {
  331.   return(Pioneer4200SendCode(theObject, "ST"));    
  332. }                                    /* end function Pioneer4200Still */
  333.  
  334.  
  335.  
  336. int
  337.   Pioneer4200Step(VideoObject*        theObject,
  338.           enum Direction    dir)
  339. {
  340.   int i;
  341.   
  342.   for (i=0; i < StepRate; ++i)
  343.     if (dir == Forward)
  344.       Pioneer4200SendCode(theObject, "SF");
  345.     else
  346.       Pioneer4200SendCode(theObject, "SR");
  347.   if (dir == Forward)
  348.     return(Pioneer4200SendCode(theObject, "SF"));
  349.   else
  350.     return(Pioneer4200SendCode(theObject, "SR"));
  351. }                                    /* end function Pioneer4200Step */
  352.  
  353.  
  354.  
  355. int
  356.   Pioneer4200FastForward(VideoObject* theObject)
  357. {
  358.   int i;
  359.   int nm1;
  360.   
  361.   nm1 = ScanRate - 1;
  362.   for (i=0; i<nm1; ++i)
  363.     Pioneer4200SendCode(theObject, "NF");
  364.   return(Pioneer4200SendCode(theObject, "NF"));
  365. }                                    /* end function Pioneer4200FastForward */
  366.  
  367.  
  368.  
  369. int
  370.   Pioneer4200Reverse(VideoObject* theObject)
  371. {
  372.   int i; 
  373.   int nm1;
  374.   
  375.   nm1 = ScanRate - 1;
  376.   for (i=0; i<nm1; ++i)
  377.     Pioneer4200SendCode(theObject, "NR");
  378.   return(Pioneer4200SendCode(theObject, "NR"));
  379. }                                    /* end function Pioneer4200Reverse */
  380.  
  381.  
  382. int
  383.   Pioneer4200PlayAtSpeedDir(VideoObject*    theObject,
  384.                 int            framesPerSecond,
  385.                 enum Direction    direction)
  386. {
  387.   char        fr[16];
  388.   int        speed;
  389.   static int    lastSpeed = 0;
  390.   
  391.   speed = framesPerSecond;
  392.   
  393.   if (speed < (FrameRate / 6))
  394.     speed = FrameRate / 10;
  395.   else if (speed < (FrameRate / 4))
  396.     speed = FrameRate / 6;
  397.   else if (speed < (FrameRate / 3))
  398.     speed = FrameRate / 4;
  399.   else if (speed < (FrameRate / 2))
  400.     speed = FrameRate / 3;
  401.   else if (speed < FrameRate)
  402.     speed = FrameRate / 2;
  403.   else if (speed < (FrameRate * 2))
  404.     speed = FrameRate;
  405.   else if (speed < (FrameRate * 3))
  406.     speed = FrameRate * 2;
  407.   else if (speed < (FrameRate * 4))
  408.     speed = FrameRate * 3;
  409.   else
  410.     speed = FrameRate * 4;
  411.   
  412.   speed = speed * 2;                            /* Pioneer4200 multiplies speed values by 2 (i.e., 60 = 1x) */
  413.   if (speed != lastSpeed)                        /* Is it really necessary to send a new command? */
  414.   {                                    /* Yes, prepare the command and send it to the player */
  415.     lastSpeed = speed;                            /* Update last speed played */
  416.     sprintf(diagMsg, "%s :\tSpeed is %d frames per second.\n",
  417.         theObject->DevConfig->serialPort,
  418.         speed);
  419.     PrintDiagnostics(diagMsg);
  420.     if (direction == Forward)
  421.       sprintf(fr,"%dSPMF",speed);
  422.     else
  423.       sprintf(fr,"%dSPMR",speed);
  424.     
  425.     return(Pioneer4200SendCode(theObject, fr));
  426.   }
  427.   else
  428.     return(PlayerOk);
  429. }                                    /* end function Pioneer4200PlayAtSpeedDir */
  430.  
  431.  
  432.  
  433. /* Returns number of frames per second. */
  434. int
  435.   Pioneer4200CalcSpeed(VideoObject*    theObject,
  436.                int        value,
  437.                int        playMode)            /* unused */
  438. {
  439.   int speed;
  440.   
  441.   if (value < 0)
  442.     value = -value;
  443.   if (value < (FrameRate / 6))                        /* 1/10th speed */
  444.     speed = FrameRate / 10;
  445.   else if (value < (FrameRate / 4))                    /* 1/6th speed */
  446.     speed = FrameRate / 6;
  447.   else if (value < (FrameRate / 3))                    /* 1/4th speed */
  448.     speed = FrameRate / 4;
  449.   else if (value < (FrameRate / 2))                    /* 1/3rd speed */
  450.     speed = FrameRate / 3;
  451.   else if (value < FrameRate)                        /* 1/2 speed */
  452.     speed = FrameRate / 2;
  453.   else if (value < (FrameRate * 2))                    /* 1x speed */
  454.     speed = FrameRate;
  455.   else if (value < (FrameRate * 3))                    /* 2x speed */
  456.     speed = FrameRate * 2;
  457.   else if (value < (FrameRate * 4))                    /* 3x speed */
  458.     speed = FrameRate * 3;
  459.   else
  460.     speed = FrameRate * 4;                        /* 4x speed */
  461.   
  462.   return (speed);
  463. }                                    /* end function Pioneer4200CalcSpeed */
  464.  
  465.  
  466. int 
  467.   Pioneer4200Power(VideoObject*    theObject,
  468.            int        value)
  469. {
  470.   /* NOT IMPLEMENTED */
  471.   return;
  472. }                                    /* end function Pioneer4200Power */
  473.  
  474.  
  475. int
  476.   Pioneer4200Search(VideoObject*    theObject,
  477.             int            to)
  478. {
  479.   char fr[16];
  480.   
  481.   sprintf(fr,"%dSE",to);
  482.   return(Pioneer4200SendCode(theObject, fr));
  483. }                                    /* end function Pioneer4200Search */
  484.  
  485.  
  486. int
  487.   Pioneer4200SetStop(VideoObject*    theObject,
  488.              int        stopM)
  489. {
  490.   char fr[16];
  491.   
  492.   sprintf(fr,"%dSM",stopM);
  493.   return(Pioneer4200SendCode(theObject, fr));
  494. }                                    /* end function Pioneer4200SetStop */
  495.  
  496.  
  497. int
  498.   Pioneer4200SetAddressDisplay(VideoObject*    theObject,
  499.                    int        on,
  500.                    int        mode)
  501. {
  502.   switch (mode)
  503.   {
  504.    case DisplayFrame:
  505.     Pioneer4200SendCode(theObject, "1RA"); 
  506.     break;
  507.    case DisplayChapter:
  508.     Pioneer4200SendCode(theObject, "2RA"); 
  509.     break;
  510.    case DisplayFrameAndChapter:    
  511.     Pioneer4200SendCode(theObject, "3RA"); 
  512.     break;
  513.   }
  514.   
  515.   if (on == FeatureOn) 
  516.     return(Pioneer4200SendCode(theObject, "1DS"));
  517.   else 
  518.     return(Pioneer4200SendCode(theObject, "0DS"));
  519. }                                    /* end function Pioneer4200SetAddressDisplay */
  520.  
  521.  
  522.  
  523. int
  524.   Pioneer4200SetAudio(VideoObject*    theObject,
  525.               int        ac)
  526. {
  527.   switch (ac)
  528.   {
  529.    case PlayerAudioMute:
  530.     return(Pioneer4200SendCode(theObject, "0AD"));
  531.     break;
  532.    case PlayerAudioLeft:
  533.     return(Pioneer4200SendCode(theObject, "1AD"));
  534.     break;
  535.    case PlayerAudioRight:
  536.     return(Pioneer4200SendCode(theObject, "2AD"));
  537.     break;
  538.    case PlayerAudioStereo:
  539.     return(Pioneer4200SendCode(theObject, "3AD"));
  540.     break;
  541.   }
  542.   return(PlayerOk);
  543. }                                    /* end function Pioneer4200SetAudio */
  544.  
  545.  
  546. int
  547.   Pioneer4200SetVideo(VideoObject*    theObject,
  548.               int        vc)
  549. {
  550.   if (vc == FeatureOn)
  551.     return(Pioneer4200SendCode(theObject, "1VD"));
  552.   else
  553.     return(Pioneer4200SendCode(theObject, "0VD"));
  554. }                                    /* end function Pioneer4200SetVideo */
  555.  
  556.  
  557. int
  558.   Pioneer4200SetAddMode(VideoObject*    theObject,
  559.             int        mode)
  560. {
  561.   switch (mode) 
  562.   {
  563.    case PlayerFrameMode:
  564.     return(Pioneer4200SendCode(theObject, "FR"));
  565.    case PlayerTimeMode:
  566.     return(Pioneer4200SendCode(theObject, "TM"));
  567.    case PlayerChapterMode:
  568.     return(Pioneer4200SendCode(theObject, "CH"));
  569.    default:
  570.     return PlayerUnknownCommand;
  571.   }
  572. }                                    /* end function Pioneer4200SetAddMode */
  573.  
  574.  
  575. int
  576.   Pioneer4200QueryFrame(VideoObject* theObject)
  577. {  
  578.   return(Pioneer4200SendCode(theObject, "?F"));
  579. }                                    /* end function Pioneer4200QueryFrame */
  580.  
  581.  
  582.  
  583. int
  584.   Pioneer4200QueryChapter(VideoObject* theObject)
  585. {  
  586.   return(Pioneer4200SendCode(theObject, "?C"));
  587. }                                    /* end function Pioneer4200QueryChapter */
  588.  
  589.  
  590. int
  591.   Pioneer4200QueryAudio(VideoObject* theObject)
  592. {  
  593.   /* NOT IMPLEMENTED */
  594.   return PlayerOk;
  595. }                                    /* end function Pioneer4200QueryAudio */
  596.  
  597.  
  598. int
  599.   Pioneer4200QueryVideo(VideoObject* theObject)
  600. {  
  601.   /* NOT IMPLEMENTED */
  602.   return PlayerOk;
  603. }                                    /* end function Pioneer4200QueryVideo */
  604.  
  605.  
  606.  
  607. /* Queries disc status */
  608. int
  609.   Pioneer4200QueryMedium(VideoObject*    theObject,
  610.              char*        result)                /* unused */
  611. {  
  612.   return(Pioneer4200SendCode(theObject, "?D"));
  613. }                                    /* end function Pioneer4200QueryMedium */
  614.  
  615.  
  616. int
  617.   Pioneer4200QueryStatus(VideoObject* theObject)
  618. {  
  619.   return(Pioneer4200SendCode(theObject, "?P"));
  620. }                                    /* end function Pioneer4200QueryStatus */
  621.  
  622.  
  623. int 
  624.   Pioneer4200Ping(VideoObject* theObject)
  625. {
  626.   int nr;
  627.   char out[5];
  628.   
  629.   write(theObject->DevConfig->fd, "?D\r", 3);                /* Query disk status command */
  630.   sprintf(diagMsg, "%s :\tSent ping.\n",
  631.       theObject->DevConfig->serialPort);
  632.   PrintDiagnostics(diagMsg);
  633.   nr = read(theObject->DevConfig->fd, out, 1);
  634.   if (nr)
  635.   {
  636.     sprintf(diagMsg, "%s :\tSuccessful ping.\n",
  637.         theObject->DevConfig->serialPort);
  638.     PrintDiagnostics(diagMsg);
  639.   }
  640.   
  641.   else 
  642.   {
  643.     sprintf(diagMsg, "%s :\tPing unsuccessful.\n",
  644.         theObject->DevConfig->serialPort);
  645.     PrintDiagnostics(diagMsg);
  646.   }
  647.   
  648.   return nr;
  649. }                                    /* end function Pioneer4200Ping */
  650.  
  651.  
  652. void 
  653.   Pioneer4200ErrorDecode(VideoObject*    theObject,
  654.              int        error,
  655.              char*        errorMsg)
  656. {
  657.   switch (error) 
  658.   {
  659.    case PlayerCantInitDevice:
  660.     strcpy(errorMsg,"Cannot initialize device properly");
  661.     break;
  662.    case PlayerInvalidBaudRate:
  663.     strcpy(errorMsg,"Baud rate is invalid");
  664.     break;
  665.    case Pioneer4200CommunicationError:
  666.     strcpy(errorMsg,"There has been a communication error");
  667.     break;
  668.    case Pioneer4200FeatureNotAvailable:
  669.     strcpy(errorMsg,"Feature/command not available in stop mode");
  670.     break;
  671.    case Pioneer4200MissingArgument:
  672.     strcpy(errorMsg,"An argument is missing");
  673.     break;
  674.    case Pioneer4200NoDisc:
  675.     strcpy(errorMsg,"Please insert a videodisc first");
  676.     break;
  677.    case Pioneer4200SearchError:
  678.     strcpy(errorMsg,"Search error");
  679.     break;
  680.    case Pioneer4200DefocussingError:
  681.     strcpy(errorMsg,"Defocussing error");
  682.     break;
  683.    case Pioneer4200PictureStop:
  684.     strcpy(errorMsg,"Picture Stop");
  685.     break;
  686.    case Pioneer4200PanicError:
  687.     strcpy(errorMsg,"CATASTROPHIC ERROR");
  688.     break;
  689.    case PlayerUnknownError:
  690.     strcpy(errorMsg,"Cannot understand error code");
  691.     break;
  692.    case PlayerUnknownReturnCode:
  693.     strcpy(errorMsg,"Cannot understand return code");
  694.     break;
  695.    case PlayerUnknownCommand:
  696.     strcpy(errorMsg,"An unknown command has been issued");
  697.    default:
  698.     strcpy(errorMsg, "Unknown error code");
  699.     break;
  700.   }
  701.   DisplayError(errorMsg, " ");
  702. }                                    /* end function Pioneer4200ErrorDecode */
  703.